From 032af4d9468312380d14b8e9ebf569bffe0cd7e8 Mon Sep 17 00:00:00 2001 From: "mjw@wray-m-3.hpl.hp.com" Date: Fri, 3 Sep 2004 09:43:59 +0000 Subject: [PATCH] bitkeeper revision 1.1159.68.2 (41383cdfHn8bdXUvTO9mrnc7pCTLGA) Send a fake ARP packet when a vif comes up, to let switches see the MAC address. --- .../drivers/xen/netfront/netfront.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c index 71105776b2..85e29d4d25 100644 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c @@ -26,6 +26,9 @@ #include #include +#include +#include + #if 0 #define DPRINTK(fmt, args...) \ printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args) @@ -171,6 +174,32 @@ static int netctrl_connected_count(void) return connected; } +/** Send a packet on a net device to encourage switches to learn the + * MAC. We send a fake ARP request. + * + * @param dev device + * @return 0 on success, error code otherwise + */ +static int vif_wake(struct net_device *dev){ + int err = 0; + struct sk_buff *skb; + u32 src_ip; + u32 dst_ip = INADDR_BROADCAST; + unsigned char dst_hw[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + + src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK); + skb = arp_create(ARPOP_REQUEST, ETH_P_ARP, + dst_ip, dev, src_ip, + dst_hw, dev->dev_addr, NULL); + if(skb == NULL){ + err = -ENOMEM; + goto exit; + } + err = dev_queue_xmit(skb); + exit: + return err; +} + static inline struct sk_buff *alloc_skb_page(void) { struct sk_buff *skb; @@ -739,6 +768,7 @@ static void netif_status_change(netif_fe_interface_status_changed_t *status) (void)request_irq(np->irq, netif_int, SA_SAMPLE_RANDOM, dev->name, dev); netctrl_connected_count(); + vif_wake(dev); break; default: -- 2.30.2